﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Pong
{
    public class Collision
    {
        public Vector2 InnerRectangleOffset(Rectangle rect1, Rectangle rect2, Vector2 CollisionDirection)
        {
            if (CollisionDirection == new Vector2(-1, 0))
            {
                return new Vector2(rect2.Left, rect1.Top);
            }
            else if (CollisionDirection == new Vector2(1, 0))
            {
                return new Vector2(rect2.Right - rect1.Width, rect1.Top);
            }
            else if (CollisionDirection == new Vector2(0, 1))
            {
                return new Vector2(rect1.Left, rect2.Bottom - rect1.Height);
            }
            else if (CollisionDirection == new Vector2(0, -1))
            {
                return new Vector2(rect1.Left, rect2.Top);
            }

            return Vector2.Zero;
        }
        public Vector2 InnerRectangleCollisionCheck(Rectangle rect1, Rectangle rec2)
        {
            if (rect1.X < rec2.X)
            {
                return new Vector2(-1, 0);
            }
            else if (rect1.Right > rec2.Right)
            {
                return new Vector2(1, 0);
            }
            else if (rect1.Top < rec2.Top)
            {
                return new Vector2(0, -1);
            }
            else if (rect1.Bottom > rec2.Bottom)
            {
                return new Vector2(0, 1);
            }

            return Vector2.Zero;
        }
       
        public Vector2 OutterRectangleOffset()
        {
            return Vector2.Zero;
        }

        public float circlePenetration(Vector2 Circle1, float Size1, Vector2 Circle2, float Size2)
        {
            float dist = Vector2.Distance(Circle1, Circle2);
            if (dist < ((Size1/2) + (Size2/2)))
            {
                return dist - ((Size1 / 2) + (Size2 / 2));
            }
          
            return 0.0f;
        }

    }
}
